//
//  UFOLQCLiveDetailsViewController.m
//  unrivalledForUniverse
//
//  Created by dllo on 1/14/16.
//  Copyright © 2016 dllo. All rights reserved.
//

#import "UFOLQCLiveDetailsViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "LQCAFNetTool.h"
#import "UFOLQCHotView.h"
#import "UFOLQCLiveModel.h"

@interface UFOLQCLiveDetailsViewController ()

@property (nonatomic, strong) AVPlayer *player;//播放器对象
@property (nonatomic, retain) UIView *playView;//播放视图
@property (nonatomic, retain) UIProgressView *progress;
@property (nonatomic, copy) NSString *liveUrl;// 直播链接
@property (nonatomic, retain) UIView *NickView;
@property (nonatomic, retain) UILabel *nickLabel;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UIImageView *nickImage;
@property (nonatomic, copy) NSString *nick; //名
@property (nonatomic, copy) NSString *titleL; //正在直播
@property (nonatomic, copy) NSString *viewNum; // 人数
@property (nonatomic, copy) NSString *avatar; //头像
@property (nonatomic, retain) UIView *viewTop;//视频
@property (nonatomic, retain) UIView *viewBottom;//视频
@property (nonatomic, retain) UIButton *buttonReturn;//返回按键
@property (nonatomic, retain) UIButton *buttonBig;//大屏按键
@property (nonatomic, retain) AVPlayerLayer *playerLayer;// 播放器
@property (nonatomic, retain) UFOLQCHotView *hotView;// 热门推荐视图
@property (nonatomic, retain) UFOLQCHotView *hotViewN;
@property (nonatomic, retain) NSMutableArray *liveArr;// 热门推荐
@property (nonatomic, retain) UIPanGestureRecognizer *panCG;//平移
@property (nonatomic, retain) UIPanGestureRecognizer *panCGN;
@property (nonatomic, retain) UITapGestureRecognizer *tapCG;//轻拍
@property (nonatomic, retain) UITapGestureRecognizer *tapCGN;


@property (nonatomic, assign) NSInteger i;

@end

@implementation UFOLQCLiveDetailsViewController

- (void)dealloc{
    [self removeObserverFromPlayerItem:self.player.currentItem];
    [self removeNotification];
    
    [_playerLayer release];
    [_roomID release];
    [_playView release];
    [_progress release];
    [_nick release];
    [_titleL release];
    [_viewNum release];
    [_avatar release];
    [_NickView release];
    [_nickLabel release];
    [_nickImage release];
    [_titleLabel release];
    [_liveUrl release];
    [_buttonReturn release];
    [_viewTop release];
    [_hotView release];
    [_hotViewN release];
    [_liveArr release];
    [_panCG release];
    [_panCGN release];
    [super dealloc];
    
}

-(void)removeObserverFromPlayerItem:(AVPlayerItem *)playerItem{
    [playerItem removeObserver:self forKeyPath:@"status"];
    [playerItem removeObserver:self forKeyPath:@"loadedTimeRanges"];
}

-(void)removeNotification{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.i = 10002;
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    UIImageView *image = [[UIImageView alloc] initWithFrame:self.view.bounds];
    image.image = [UIImage imageNamed:@"b28921b0144b6ece998b3e99e6f84c4e.jpg"];
    [self.view addSubview:image];
    [image release];
    // 播放 窗口
    [self createPlayView];
    
    self.hotView = [UFOLQCHotView new];
    self.hotView.layer.shadowColor = [[UIColor blackColor] CGColor];
    self.hotView.layer.shadowOffset = CGSizeMake(2, 5);
    self.hotView.layer.shadowRadius = 5;
    self.hotView.layer.shadowOpacity = 0.8;
    self.hotView.tag = 10000;
    [self.view addSubview:self.hotView];
    
    [self.hotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(50);
        make.right.equalTo(self.view).offset(-50);
        make.height.mas_offset(@200);
        make.top.equalTo(self.NickView.mas_bottom).offset(80);
    }];
    
    self.hotView = [UFOLQCHotView new];
    self.hotView.layer.shadowColor = [[UIColor blackColor] CGColor];
    self.hotView.layer.shadowOffset = CGSizeMake(2, 5);
    self.hotView.layer.shadowRadius = 5;
    self.hotView.layer.shadowOpacity = 0.8;
    self.hotView.tag = 10001;
    [self.view addSubview:self.hotView];
    
    [self.hotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(50);
        make.right.equalTo(self.view).offset(-50);
        make.height.mas_offset(@200);
        make.top.equalTo(self.NickView.mas_bottom).offset(80);
    }];
    self.tapCG = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCGAction:)]autorelease];
    [[self.view viewWithTag:10000] addGestureRecognizer:self.tapCG];
    
    self.tapCGN = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCGAction:)]autorelease];
    [[self.view viewWithTag:10001] addGestureRecognizer:self.tapCGN];
    
    self.panCG = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)]autorelease];
    [[self.view viewWithTag:10000] addGestureRecognizer:self.panCG];
    
    self.panCGN = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)]autorelease];
    [[self.view viewWithTag:10001] addGestureRecognizer:self.panCGN];
    
    [self.view  bringSubviewToFront:[self.view viewWithTag:10000]];
    [self createGetData];
    
    UILabel *numLabel = [UILabel new];
    numLabel.text = @"Hot Player!!!";
    numLabel.font = [UIFont fontWithName:@"Zapfino" size:35];
    numLabel.backgroundColor = [UIColor clearColor];
    numLabel.textColor = [UIColor redColor];
    numLabel.textAlignment = NSTextAlignmentCenter;
    numLabel.layer.shadowColor = [[UIColor redColor] CGColor];
    numLabel.layer.shadowOffset = CGSizeMake(3, 5);
    numLabel.layer.shadowRadius = 3;
    numLabel.layer.shadowOpacity = 10;
    [self.view addSubview:numLabel];
    
    [numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view).offset(-30);
        make.bottom.equalTo(self.view).offset(-5);
        make.height.mas_offset(@80);
        
    }];
    
}

//- (void)viewDidDisappear:(BOOL)animated{
//    [self.player pause];
//    //self.play = nil;
//    [super viewDidDisappear:animated];
//}

- (void)tapCGAction:(UITapGestureRecognizer *)sender
{
    UFOLQCLiveModel *liveM = [self.liveArr objectAtIndex:sender.view.tag- 10000];
    
    self.roomID = liveM.uid;
    
    //    [self removeNotification];
    //    [self removeObserverFromPlayerItem:self.player.currentItem];
    //    AVPlayerItem *playerItem=[self getPlayItem];
    //    [self addObserverToPlayerItem:playerItem];
    //    //切换视频
    //    [self.player replaceCurrentItemWithPlayerItem:playerItem];
    //
    
    
    
    
    [self.player play];
    
    
}

- (void)createPlayView{
    // 视频view
    self.playView = [[[UIView alloc] initWithFrame:CGRectMake(0, 20, SCREENWIDTH, SCREENWIDTH * SCREENWIDTH / SCREENHEIGHT)] autorelease];
    self.playView.backgroundColor = [UIColor grayColor];
    [self.view addSubview:self.playView];
    
    // 标题栏 底视图
    self.NickView = [UIView new];
    self.NickView.backgroundColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    [self.view addSubview:self.NickView];
    
    // 头像
    self.nickImage = [UIImageView new];
    [self.view addSubview:self.nickImage];
    
    // 直播间名
    self.nickLabel = [UILabel new];
    [self.view addSubview:self.nickLabel];
    
    // 详情
    self.titleLabel = [UILabel new];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    self.titleLabel.textColor = [UIColor colorWithWhite:0.298 alpha:1.000];
    [self.view addSubview:self.titleLabel];
    
    [self.NickView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view).offset(0);
        make.top.equalTo(self.playView.mas_bottom).offset(0);
        make.height.mas_offset(@50);
    }];
    
    
    [self.nickImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self.NickView).offset(0);
        make.width.mas_offset(@50);
    }];
    
    
    [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.equalTo(self.NickView).offset(0);
        make.left.equalTo(self.nickImage.mas_right).offset(0);
        make.height.mas_offset(@30);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.right.equalTo(self.NickView).offset(0);
        make.top.equalTo(self.nickLabel.mas_bottom).offset(0);
        make.left.equalTo(self.nickImage.mas_right).offset(0);
    }];
    
    
    [self setupUI];
    
    // 上灰
    self.viewTop = [UIView new];
    self.viewTop.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.540];
    [self.playView addSubview:self.viewTop];
    //下灰
    self.viewBottom = [UIView new];
    self.viewBottom.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.540];
    [self.playView addSubview:self.viewBottom];
    // 返回键
    self.buttonReturn = [UIButton new];
    [self.buttonReturn  setImage:[UIImage imageNamed:@"tuichu"] forState:UIControlStateNormal];
    [self.buttonReturn addTarget:self action:@selector(retionAction) forControlEvents:UIControlEventTouchUpInside];
    [self.viewTop addSubview:self.buttonReturn];
    // 全屏/小屏建
    self.buttonBig = [UIButton new];
    [self.buttonBig  setImage:[UIImage imageNamed:@"jinruquanping"] forState:UIControlStateNormal];
    [self.buttonBig  setImage:[UIImage imageNamed:@"tuichuquanping"] forState:UIControlStateSelected];
    [self.buttonBig addTarget:self action:@selector(bigAction) forControlEvents:UIControlEventTouchUpInside];
    [self.viewBottom addSubview:self.buttonBig];
    
    
    [self.viewTop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.playView).offset(0);
        make.height.mas_offset(@40);
    }];
    
    [self.viewBottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.playView).offset(0);
        make.height.mas_offset(@40);
    }];
    
    [self.buttonReturn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.equalTo(self.viewTop).offset(0);
        make.width.mas_offset(@40);
    }];
    
    [self.buttonBig mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.equalTo(self.viewBottom).offset(0);
        make.width.mas_offset(@40);
    }];
    
    // 轻拍
    UITapGestureRecognizer *tapGRP = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewAction)] autorelease];
    [self.playView addGestureRecognizer:tapGRP];
    
    
    [self createGetLiveData];
}

// 返回方法
- (void)retionAction{
    [self.player replaceCurrentItemWithPlayerItem:nil];
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
// 数据请求
- (void)createGetData{
    [LQCAFNetTool getNetWithURL: [NSString stringWithFormat:@"http://www.quanmin.tv/json/rooms/%@/info.json?01151026",self.roomID]body:nil headFile:nil responseStyle:LQCJSON success:^(NSURLSessionDataTask *task, id responseObject) {
        
        self.avatar = [responseObject objectForKey:@"avatar"];
        self.nick = [responseObject objectForKey:@"nick"];
        self.titleL = [responseObject objectForKey:@"title"];
        self.viewNum = [responseObject objectForKey:@"view"];
        
        NSURL *imageUrl = [NSURL URLWithString:self.avatar];
        [self.nickImage sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"zanweitu"]];
        self.nickLabel.text = self.nick;
        self.titleLabel.text = [NSString stringWithFormat:@" 正在直播:%@",self.titleL];
        [self.player play];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}

#pragma mark - 私有方法
-(void)setupUI{
    //创建播放器层
    self.playerLayer=[AVPlayerLayer playerLayerWithPlayer:self.player];
    self.playerLayer.frame = CGRectMake(0, 0, self.playView.frame.size.width, self.playView.frame.size.height);
    // playerLayer.videoGravity=AVLayerVideoGravityResizeAspect;//视频填充模式
    
    [self.playView.layer addSublayer:self.playerLayer];
}

- (AVPlayer *)player{
    if (!_player) {
        AVPlayerItem *playerItem = [self getPlayItem];
        _player = [AVPlayer playerWithPlayerItem:playerItem];
        [self addProgressObserver];
        [self addObserverToPlayerItem:playerItem];
    }
    return _player;
}

- (AVPlayerItem *)getPlayItem{
    
    NSString *urlStr = [NSString stringWithFormat:@"http://hls.quanmin.tv/live/%@/playlist.m3u8", self.roomID];
    NSURL *url = [NSURL URLWithString:urlStr];
    AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];
    return playerItem;
}

-(void)addNotification{
    //给AVPlayerItem添加播放完成通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:self.player.currentItem];
}

-(void)addProgressObserver{
    AVPlayerItem *playerItem=self.player.currentItem;
    UIProgressView *progress=self.progress;
    //这里设置每秒执行一次
    [self.player addPeriodicTimeObserverForInterval:CMTimeMake(1.0, 1.0) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
        float current=CMTimeGetSeconds(time);
        float total=CMTimeGetSeconds([playerItem duration]);
        NSLog(@"当前已经播放%.2fs.",current);
        if (current) {
            [progress setProgress:(current/total) animated:YES];
        }
    }];
}

-(void)addObserverToPlayerItem:(AVPlayerItem *)playerItem{
    //监控状态属性，注意AVPlayer也有一个status属性，通过监控它的status也可以获得播放状态
    [playerItem addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];
    //监控网络加载情况属性
    [playerItem addObserver:self forKeyPath:@"loadedTimeRanges" options:NSKeyValueObservingOptionNew context:nil];
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
    AVPlayerItem *playerItem=object;
    if ([keyPath isEqualToString:@"status"]) {
        AVPlayerStatus status= [[change objectForKey:@"new"] intValue];
        if(status==AVPlayerStatusReadyToPlay){
            NSLog(@"正在播放...，视频总长度:%.2f",CMTimeGetSeconds(playerItem.duration));
        }
    }else if([keyPath isEqualToString:@"loadedTimeRanges"]){
        NSArray *array=playerItem.loadedTimeRanges;
        CMTimeRange timeRange = [array.firstObject CMTimeRangeValue];//本次缓冲时间范围
        float startSeconds = CMTimeGetSeconds(timeRange.start);
        float durationSeconds = CMTimeGetSeconds(timeRange.duration);
        NSTimeInterval totalBuffer = startSeconds + durationSeconds;//缓冲总长度
        NSLog(@"共缓冲：%.2f",totalBuffer);
        //
    }
}
// 播放栏
- (void)viewAction{
    if (self.viewTop.hidden == YES && self.viewBottom.hidden == YES) {
        self.viewTop.hidden = NO;
        self.viewBottom.hidden = NO;
    }
    else if (self.viewTop.hidden == NO && self.viewBottom.hidden == NO) {
        self.viewTop.hidden = YES;
        self.viewBottom.hidden = YES;
    }
}
// 全屏方法
- (void)bigAction{
    if (self.buttonBig.selected == NO) {
        self.buttonBig.selected = YES;
        self.view.transform = CGAffineTransformMakeRotation(- M_PI*1.5);
        [UIView commitAnimations];
        
        //        CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
        //        //设置旋转动画
        //        [UIView beginAnimations:nil context:nil];
        //        [UIView setAnimationDuration:duration];
        //设置视图旋转
        
        self.playView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
        self.playerLayer.frame = self.playView.frame;
        self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
        
    }else if (YES == self.buttonBig.selected){
        self.buttonBig.selected = NO;
        self.view.transform = CGAffineTransformMakeRotation(M_PI*0);
        
        //        CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
        //        //设置旋转动画
        //        [UIView beginAnimations:nil context:nil];
        //        [UIView setAnimationDuration:duration];
        
        self.playView.frame = CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.height * self.view.frame.size.height / self.view.frame.size.width);
        self.playerLayer.frame = self.playView.frame;
        self.view.bounds = CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width);
    }
    
}

#pragma 热门数据请求
- (void)createGetLiveData{
    [LQCAFNetTool getNetWithURL:@"http://www.quanmin.tv/json/categories/lol/list.json?01141551" body:nil headFile:nil responseStyle:LQCJSON success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSMutableArray *arr = [responseObject objectForKey:@"data"];
        self.liveArr = [UFOLQCLiveModel baseModelWithArr:arr];
        
        
        UFOLQCLiveModel *liveM = [self.liveArr objectAtIndex:0];
        self.hotView = [self.view viewWithTag:10000];
        NSURL *imageUrl = [NSURL URLWithString:liveM.thumb];
        
        [self.hotView.hotImageView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"zanweitu"]];
        self.hotView.hotNameLabel.text = liveM.nick;
        self.hotView.hotNumLabel.text = [NSString stringWithFormat:@"👤%@",liveM.view];
        self.hotView.hotTitleLabel.text = liveM.title;
        self.hotView.roomID = liveM.uid;
        
        UFOLQCLiveModel *liveM1 = [self.liveArr objectAtIndex:1];
        self.hotView = [self.view viewWithTag:10001];
        NSURL *imageUrl1 = [NSURL URLWithString:liveM1.thumb];
        [self.hotView.hotImageView sd_setImageWithURL:imageUrl1 placeholderImage:[UIImage imageNamed:@"zanweitu"]];
        self.hotView.hotNameLabel.text = liveM1.nick;
        self.hotView.hotNumLabel.text = [NSString stringWithFormat:@"👤%@",liveM1.view];
        self.hotView.hotTitleLabel.text = liveM1.title;
        self.hotView.roomID = liveM.uid;
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}
#pragma 平移方法
- (void)panAction:(UIPanGestureRecognizer *)sender{
    
    sender.view.center = [sender locationInView:self.view];
    if (sender.state == UIGestureRecognizerStateEnded) {
        
        if (sender.view.center.x > 80 && sender.view.center.y < SCREENHEIGHT - 80 && sender.view.center.y > SCREENHEIGHT - 300 && sender.view.center.x < SCREENWIDTH - 80) {
            [UIView animateWithDuration:0.2 animations:^{
                sender.view.center = CGPointMake(SCREENWIDTH / 2, 461 * HEIGHTSIXP / SCREENHEIGHT);
            }];
        }
        else if ( sender.view.center.x < 80 || sender.view.center.y > SCREENHEIGHT - 80 || sender.view.center.y < SCREENHEIGHT - 300 || sender.view.center.x > SCREENWIDTH - 80) {
            if (sender.view.center.x < SCREENWIDTH / 2) {
                [UIView animateWithDuration:0.2 animations:^{
                    sender.view.frame = CGRectMake(- 375, sender.view.frame.origin.y, sender.view.frame.size.width,sender.view.frame.size.height);
                    
                } completion:^(BOOL finished) {
                    [sender.view removeFromSuperview];
                    [self CreateNewView];
                    
                }];
            } else if (sender.view.center.x >= SCREENWIDTH / 2){
                
                [UIView animateWithDuration:0.2 animations:^{
                    sender.view.frame = CGRectMake(375, sender.view.frame.origin.y, sender.view.frame.size.width,sender.view.frame.size.height);
                    
                } completion:^(BOOL finished) {
                    [sender.view removeFromSuperview];
                    [self CreateNewView];
                }];
            }
        }
    }
}
#pragma 创建新视图
- (void)CreateNewView{
    if (self.i - 9999 > self.liveArr.count) {
        UILabel *label = [UILabel new];
        label.text = @"没有更多推荐😨";
        label.textAlignment = NSTextAlignmentCenter;
        label.backgroundColor = [UIColor colorWithRed:1.000 green:0.000 blue:0.502 alpha:1.000];
        [self.view addSubview:label];
        
        [self.view bringSubviewToFront:[self.view viewWithTag:self.i - 1]];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(50);
            make.right.equalTo(self.view).offset(-50);
            make.height.mas_offset(@200);
            make.top.equalTo(self.NickView.mas_bottom).offset(80);
        }];
        
        
    }else if (self.i - 9999 <= self.liveArr.count){
        self.hotView = [UFOLQCHotView new];
        self.hotView.layer.shadowColor = [[UIColor blackColor] CGColor];
        self.hotView.layer.shadowOffset = CGSizeMake(2, 5);
        self.hotView.layer.shadowRadius = 5;
        self.hotView.layer.shadowOpacity = 0.8;
        self.hotView.tag = self.i;
        [self.view addSubview:self.hotView];
#pragma 视图置前
        [self.view bringSubviewToFront:[self.view viewWithTag:self.i - 1]];
        
        [self.hotView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(50);
            make.right.equalTo(self.view).offset(-50);
            make.height.mas_offset(@200);
            make.top.equalTo(self.NickView.mas_bottom).offset(80);
        }];
#pragma 添加手势  避免重复添加
        if (0 == self.i % 2) {
            [[self.view viewWithTag:self.i] addGestureRecognizer:self.panCG];
            [[self.view viewWithTag:self.i] addGestureRecognizer:self.tapCG];
        }else if (0 != self.i % 2){
            [[self.view viewWithTag:self.i] addGestureRecognizer:self.panCGN];
            [[self.view viewWithTag:self.i] addGestureRecognizer:self.tapCGN];
        }
        
#pragma 添加数据
        UFOLQCLiveModel *liveM = [self.liveArr objectAtIndex:self.i - 10000];
        self.hotView = [self.view viewWithTag:self.i];
        NSURL *imageUrl = [NSURL URLWithString:liveM.thumb];
        [self.hotView.hotImageView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"zanweitu"]];
        self.hotView.hotNameLabel.text = liveM.nick;
        self.hotView.hotNumLabel.text = [NSString stringWithFormat:@"👤%@",liveM.view];
        self.hotView.hotTitleLabel.text = liveM.title;
        self.hotView.roomID = liveM.uid;
        
        self.i += 1;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
